// Raf Lempens & Bjorn Schobben
#include "Laser.h"
#include "ActivateAbility.h"

Laser::Laser(unsigned int initialCellX, unsigned int initialCellY): GameObject(initialCellX, initialCellY), activateAbility(0), blockMoveAbility(0), setTargetAbility(0)
{
	// Setup abilities
	activateAbility = new ActivateAbility(this);
	setTargetAbility = new SetTargetAbility(this);
	blockMoveAbility = new BlockMoveAbility();

	AddAbility(activateAbility);
	AddAbility(blockMoveAbility);
	AddAbility(setTargetAbility);

	// Setup behaviour
	behavior.SetActivator(this, this);
}

Laser::~Laser()
{
	if (activateAbility)
	{
		delete activateAbility;
		activateAbility = 0;
	}

	if (blockMoveAbility)
	{
		delete blockMoveAbility;
		blockMoveAbility = 0;
	}

	if (setTargetAbility)
	{
		delete setTargetAbility;
		setTargetAbility = 0;
	}
}

void Laser::SetDirection(const Direction& direction)
{
	wallDirection = direction;
	behavior.SetShootDirection(direction.Opposed());
	blockMoveAbility->SetBlockDirection(direction);
}

void Laser::Activate()
{
	printf("Laser activated\n");
}

void Laser::SetTarget(GameObject* target)
{
	printf("Setting target %x\n", target);
}

GameBehavior* Laser::GetBehavior()
{
	return &behavior;
}
